<template>
	<view>
		<view class="" style="width: 100%;height: 20rpx;"></view>
		<view class="row" @click="bingPhoneNumber">
			<view class="row-title util-font-regular">手机号</view>
			<image class="row-image" src="../../static/mine/arrow-right.png" mode="aspectFit"></image>
			<view class="row-text util-font-regular">{{phone.length?phone:"未绑定"}}</view>
		</view>
		<view class="row" @click="bingWechatNumber">
			<view class="row-title util-font-regular">微信号</view>
			<image class="row-image" src="../../static/mine/arrow-right.png" mode="aspectFit"></image>
			<view class="row-text util-font-regular">{{wechatNo.length?wechatNo:"未绑定"}}</view>
		</view>
		
		<!-- 我的微信号 -->
		<uni-popup id="myWechatNoDialog" ref="myWechatNoDialog" type="dialog">
			<uni-popup-dialog mode="input" title="填写/修改微信号" :value="wechatNo" placeholder="请输入您的微信号" @confirm="myWechatNoDialogConfirm"></uni-popup-dialog>
		</uni-popup>
	</view>
</template>

<script>
	import uniPopup from "../../components/uni-popup/uni-popup.vue"
	import uniPopupDialog from '@/components/uni-popup/uni-popup-dialog.vue'
	export default {
		components: {
			uniPopup,
			uniPopupDialog
			
		},
		data() {
			return {
				userInfo: null,
				
				phone: '',
				wechatNo: '',
				
			}
		},
		onLoad() {
			var that = this
			uni.$on("getPhoneNumberSuccess", function(){
				uni.showToast({
					title: '手机号绑定成功'
				});
			})
			this.userInfo = uni.getStorageSync("userInfo")
			this.wechatNo = this.userInfo.wechat
			this.phone = this.userInfo.phone
		},
		onShow() {
			this.userInfo = uni.getStorageSync("userInfo")
			this.wechatNo = this.userInfo.wechat
			this.phone = this.userInfo.phone
		},
		methods: {
			bingPhoneNumber: function(){
				this.getPhoneNumber()
			},
			bingWechatNumber: function(){
				this.$refs.myWechatNoDialog.open()
			},
			myWechatNoDialogConfirm: function(done, value){
				this.$refs.myWechatNoDialog.close()
				var that = this
				that.sendRequest({
					url: 'app/appUser/update',
					method: "POST",
					header: that.$urlRequest.getHeader('token','json'),
					data: {
						id: that.userInfo.id,
						wechat: value
					},
					success: function(res) {
						that.userInfo.wechat = value
						that.wechatNo = value
						uni.setStorageSync('userInfo', that.userInfo)
					}
				})
			},
		}
	}
</script>

<style>
	page {
		background-color: #F5F5F5;
	}
	
	.row {
		width: 100%;
		height: 110rpx;
		border-bottom: 2rpx solid #F1F1F1;
		background-color: white;
	}
	.row-title {
		height: 110rpx;
		line-height: 110rpx;
		font-size: 34rpx;
		color: #333333;
		float: left;
		margin-left: 30rpx;
	}
	.row-image {
		width: 15rpx;
		height: 30rpx;
		margin-right: 30rpx;
		margin-top: 40rpx;
		float: right;
	}
	.row-text {
		height: 110rpx;
		line-height: 110rpx;
		font-size: 30rpx;
		color: #666666;
		float: right;
		margin-right: 30rpx;
	}
</style>
